package com.lapelife.backend.mapper;

import com.lapelife.backend.domain.entity.SysRole;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
* @author Mir.Lliao
* @description 针对表【sys_role(角色信息表)】的数据库操作Mapper
* @createDate 2023-04-25 20:05:56
* @Entity com.lapelife.backend.model.domain.SysRole
*/
@Repository
public interface SysRoleMapper extends BaseMapper<SysRole> {
    Integer addRoleToUser(@Param("roleIdList") List<Long> roleIdlist, @Param("userId") Long userId);

    Integer selectRoleCount(@Param("roleName") String roleName, @Param("roleKey") String roleKey);

    /**
     * 查询是否有用户使用该角色
     * @param roleId 角色id
     * @return 用户数量
     */
    Integer selectHasRoleUserCount(@Param("roleId") Long roleId);

    Integer countRoleRelation(@Param("roleId") Long roleId);

    Integer deleteRoleFor(@Param("userId") Long userId, @Param("roleIdList") List<Long> roleIdList);
}




